package thirtparty;

import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;

import app.auto.AndroidInstance;

//api 'com.qmuiteam:qmui:1.4.0'
public class LoadingDialog extends AndroidInstance {

    public void demo(){
        LoadingDialog.reservSin(LoadingDialog.class,getContext()).showLoadingDialog();
        LoadingDialog.reservSin(LoadingDialog.class,getContext()).dismissLoadingDialog();

    }
    private QMUITipDialog loadingDialog;

    @Override
    public AndroidInstance use(Object mp, Object... p) {
        return null;
    }

    protected void showLoadingDialog() {
        if (loadingDialog != null) {
            loadingDialog.dismiss();
        }
        loadingDialog =
                new QMUITipDialog.Builder(getContext()).setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING).setTipWord("加载中...").create(false);
        if (!loadingDialog.isShowing()) {
            loadingDialog.show();
        }
    }

    /**
     * 隐藏进度条
     */
    protected void dismissLoadingDialog() {
        if (loadingDialog != null) {
            loadingDialog.dismiss();
        }
    }

}
